﻿@{
    Layout = "~/Views/Shared/_LayoutForm.cshtml";
}

<div class="col-xs-12">
    <form id="editForm" class="form-horizontal" role="form">
        <div class="alert alert-warning hidden" id="msgAlert">
            <span id="spErrorMsg"></span>
        </div>
        <div class="row">
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-xs-3 control-label no-padding-right" for="Name">模块名称</label>
                    <span class="col-xs-7">
                        <input field="Name" type="text" id="Name" name="Name" class="col-xs-12" placeholder="模块名称" check-type="required" />
                    </span>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-xs-3 control-label no-padding-right" for="Name">模块图标</label>
                    <span class="col-xs-7">
                        <i id="IconStyle"></i> &nbsp;&nbsp;&nbsp;&nbsp;
                        <button class="btn btn-primary btn-xs" id="btnSelectIcon">
                            <i class="ace-icon fa fa-smile-o  bigger-110 icon-only"></i>
                            选择
                        </button>
                        <input type="hidden" id="Icon" name="Icon" field="Icon" />
                    </span>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-xs-3 control-label no-padding-right" for="Name">控制器</label>
                    <span class="col-xs-7">
                        <select id="Controller" name="Controller" field="Controller" class="form-control"></select>
                    </span>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-xs-3 control-label no-padding-right" for="Name">动作</label>
                    <span class="col-xs-7">
                        <select class="form-control" id="Action" name="Action" field="Action"></select>
                    </span>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-xs-3 control-label no-padding-right" for="Name">链接地址</label>
                    <span class="col-xs-7">
                        <input field="LinkAddress" type="text" id="LinkAddress" name="LinkAddress" class="col-xs-12" placeholder="链接地址" check-type="required" />
                    </span>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-xs-3 control-label no-padding-right" for="Name">模块类型</label>
                    <span class="col-xs-7">
                        @*<input field="Type" id="Type" name="Type" class="col-xs-12" placeholder="模块类型" check-type="required" />*@
                        <select field="Type" id="Type" name="Type" class="form-control">
                            <option value="1">菜单</option>
                            <option value="2">按钮</option>
                            <option value="3">请求</option>
                        </select>
                    </span>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-xs-3 control-label no-padding-right" for="Name">排序值</label>
                    <span class="col-xs-7">
                        <input field="Sort" type="text" id="Sort" name="Sort" class="col-xs-12" placeholder="排序值" />
                    </span>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-xs-3 control-label no-padding-right" for="IsVisible">是否有效</label>
                    <div class="col-xs-7">
                        <input type="checkbox" ctype="switch" id="IsVisible" name="IsVisible" field="IsVisible" data-size="small" data-off-text="No" data-on-text="Yes">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div class="form-group" style="margin-left:3%">
                    <label class="col-xs-1 control-label no-padding-right" for="Remark">备注</label>
                    <div class="col-xs-10">
                        <textarea field="Remark" id="Remark" name="Remark" class="col-xs-12" maxlength="200" style="position:static"></textarea>
                    </div>
                </div>
            </div>
        </div>
        <input type="hidden" id="Id" name="Id" field="Id" />
        <input type="hidden" id="ParentId" name="ParentId" field="ParentId" />
    </form>
</div>
<script type="text/javascript">
    $(function () {
        xcore.initForm($("#editForm"));
        //初始化下拉框
        $("#Controller").append("<option value=''>-请选择-</option>");
        $("#Action").append("<option value=''>-请选择-</option>");

        $("#btnSelectIcon").click(function () {
            xcore.showHtml({ url: "SelectIcon", title: "选择图标" }, function (dialog) {
                $("a", dialog).click(function () {
                    $("#IconStyle").attr("class", $("i", $(this)).attr("class") + " bigger-130");
                    $("#Icon").val($("i", $(this)).attr("class"));
                    dialog.modal("hide");
                    return true;
                });
            });
            return false;
        });

        //控制器选项改变
        $("#Controller").bind("change", function () {
            var controller = $(this).children('option:selected').val();
            $("#Action").children().remove();
            xcore.ajax("GetAction", { controllName: controller }, function (result) {
                $.each(result, function (key, value) {
                    $("#Action").append("<option value='" + value.ActionName + "'>" + value.ActionName + "(" + value.Description + ")</option>");
                });
            });
        });

        //动作选择改变，更改链接
        $("#Action").bind("change", function () {
            var controller = $("#Controller").children('option:selected').val();
            var action = $("#Action").children('option:selected').val();
            $("#LinkAddress").val(controller + "/" + action);
        });
    });
</script>